﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using RestUpMVC.Resource;
using RestUpMVC.Test.TestClasses;

namespace RestUpMVC.Test.Resource
{
    [TestClass]
    public class ResourceParentResolverTest
    {
        [TestMethod]
        public void ResolveMetaData_ShouldSetTheParentTypeProperty()
        {
            var parentResolver = new ResourceParentResolver();
            var metaData = new ResourceMetaData();

            parentResolver.ResolveMetaData(typeof(TestResource), metaData);

            Assert.AreSame(typeof(ParentResource), metaData.ParentResource);
        }

        [TestMethod]
        public void ResolveMetaData_ShouldLeaveTheParentTypePropertyNullWhenThereIsNoParent()
        {
            var parentResolver = new ResourceParentResolver();
            var metaData = new ResourceMetaData();

            parentResolver.ResolveMetaData(typeof(ParentResource), metaData);

            Assert.IsNull(metaData.ParentResource);
        }
    }
}